package com.phx.serialjni;


import android.app.Activity;
import android.content.ComponentName;
import android.content.Intent;
import android.content.ServiceConnection;
import android.os.IBinder;
import android.support.v7.app.AppCompatActivity;
import android.view.KeyEvent;
import android.view.MotionEvent;
import android.view.View;
import android.view.WindowManager;
import android.view.animation.Animation;
import android.view.animation.LinearInterpolator;
import android.view.animation.RotateAnimation;

/**

 * @version
 *
 */
public abstract class BaseActivity extends Activity {
	//protected IBackService iBackService;
	protected ServiceConnection connection = new ServiceConnection() {

		@Override
		public void onServiceDisconnected(ComponentName name) {
			//iBackService = null;
		}

		@Override
		public void onServiceConnected(ComponentName name, IBinder service) {
	//		iBackService = IBackService.Stub.asInterface(service);
		}
	};
	protected Intent mServiceIntent;
	@Override
	public boolean onKeyDown(int keyCode, KeyEvent event) {
		if (keyCode == KeyEvent.KEYCODE_BACK
				&& event.getAction() == KeyEvent.ACTION_DOWN) {
//            for (Activity activity : ParameterSetActivity.activityList) {
//                activity.finish();
//            }
			this.finish();
			System.exit(0);
			return true;
		}
		return super.onKeyDown(keyCode, event);
	}
	//public abstract boolean onInterceptTouchEvent(MotionEvent ev);

	public void showSystemUI() {
		getWindow().getDecorView().setSystemUiVisibility(View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN);
		getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN);
	}

	public void rotateViewWithAngle(float f, float f2, View view, int i) {
		Animation rotateAnimation = new RotateAnimation(f, f2, 1, 0.5f, 1, 0.5f);
		rotateAnimation.setInterpolator(new LinearInterpolator());
		rotateAnimation.setDuration((long) i);
		//rotateAnimation.setFillAfter(Float.min(0));
		view.startAnimation(rotateAnimation);
	}
}
